package com.alita.redis.scheduler;

import com.alita.redis.service.RedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import static com.alita.redis.utils.time.TimeUtil.getCurrentHHmmTime;


@Component
public class RedisPageCacheMonitorScheduler {

    private final static Logger logger = LoggerFactory.getLogger(RedisPageCacheMonitorScheduler.class);

    @Autowired
    private RedisService redisService;

    @Scheduled(cron = "${myScheduler.corn.taskNumMonitor}")
    public void execute() {
        double time = getCurrentHHmmTime();
        if ((time >= 9.00 && time <= 12.00) || (time >= 13.30 && time <= 23.00)){
            redisService.scanKey(":total:");
        }
    }
}
